package com.web.article;

import com.bean.Article;
import com.service.ArticleService;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

public class ListArticleServlet extends HttpServlet {
    @Override
    public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }

    @Override
    public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        ArticleService service=new ArticleService();
        try{
            List<Article> La=service.getAllArticle();
            req.getSession().setAttribute("listarticle",La);
            // 4.重定向到list.jsp页面
            //req.getRequestDispatcher("front/article/ArticleList.jsp").forward(req, resp);

            req.getRequestDispatcher("/admin/article/ArticleList.jsp").forward(req, resp);


        }catch (Exception e){
            e.printStackTrace();
        }

    }
}
